package com.ruoyi.common.pms.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.common.business.entity.YytMember;
import com.ruoyi.common.business.service.YytMemberService;
import com.ruoyi.common.oms.entity.YytOmsOrder;
import com.ruoyi.common.oms.service.YytOmsOrderService;
import com.ruoyi.common.pms.entity.YytMaaSubscribeStore;
import com.ruoyi.common.pms.dao.YytMaaSubscribeStoreMapper;
import com.ruoyi.common.pms.service.YytMaaSubscribeStoreService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.vo.ResultStoreVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
* <p>
    * 预约到店表 服务实现类
    * </p>
*
* @author MrPing
* @since 2022-03-14
*/
@Service
public class YytMaaSubscribeStoreServiceImpl extends ServiceImpl<YytMaaSubscribeStoreMapper, YytMaaSubscribeStore> implements YytMaaSubscribeStoreService {

    @Resource
    private YytMaaSubscribeStoreMapper yytMaaSubscribeStoreMapper;

    @Autowired
    private YytOmsOrderService yytOmsOrderService;

    @Autowired
    private YytMemberService yytMemberService;


    @Override
    public List<ResultStoreVo> getOrderOrProduct(String wxId, String status, String orderId) {
        // TODO 旧代码
        //  return yytMaaSubscribeStoreMapper.getOrderOrProduct(wxId, status, orderId);

        if(orderId != null){
            YytOmsOrder omsOrder = yytOmsOrderService.getById(orderId);
            YytMember yytMember = yytMemberService.getById(omsOrder.getMemberId());
            return yytMaaSubscribeStoreMapper.getOrderOrProduct(yytMember.getId(), status, orderId);
        }else{
            return yytMaaSubscribeStoreMapper.getOrderOrProduct(wxId, status, orderId);
        }
    }
}
